package com.hyzh.hj212.client;

import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.timeout.IdleStateEvent;

/**
 * @author songkui
 * @since 2024/8/5 18:19
 */
public class HeartHandler extends ChannelDuplexHandler {
    @Override
    public void userEventTriggered(final ChannelHandlerContext ctx, Object evt) throws Exception {
        if (evt instanceof IdleStateEvent) {
            ctx.writeAndFlush( "ping" + "\r\n");
        } else {
            super.userEventTriggered(ctx, evt);
        }
    }

}
